<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <!-- 注意: 先引入 react基础库,再引入react dom解析库 -->
  <script src="lib/react/react.development.js"></script>
  <script src="lib/react/react-dom.development.js"></script>
  <script src="lib/babel.min.js"></script>
</head>
<body>
  <!-- 创建react解析的容器 -->
  <div id="root"></div>
  <script type="text/babel">
    class HelloWorld extends React.Component {
      // 1. onClick 应该是驼峰
      // 2. 传入一个事件对象,而非字符串
      say(event){
        console.log('e',event);
        console.log('say...');
      }
      jumpTo(e){
          // 阻止默认
          e.preventDefault();
          console.log('e.target',e.target);
      }
      // 函数传参
      deleteItem(id,e){
        console.log('元素:'+id+'删除成功!');
        console.log('e.target',e.target);
      }
      render(){
        return (
          <div>
            <h1 onClick={this.say}>点击</h1>
            <a href="http://bufanui.com" onClick={this.jumpTo}>不凡学院</a>
            <p onClick={e=>this.deleteItem(1,e)}>删除元素1</p>
          </div>
        )
      }
    }
    // 使用react 相关api 渲染到容器
    ReactDOM.render(<HelloWorld />,document.getElementById('root'));
  </script>
</body>
</html>